﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	
	/**
	 * ...
	 * @author wwx
	 * 10000002 退出
	 */
	public class EnterRoomCmdReq extends abCommand
	{
		
		public function EnterRoomCmdReq() //: abCommand(CommandType.CMD_TYPE_ENTERROOM_REQ)
		{
			super(CommandType(CommandType.CMD_TYPE_ENTERROOM_REQ));
			msgSeq = 10000003;
		}
		
		private var msgSeq:int;//消息号
		public var reserve:int;//保留字段
		
		public var roomId:int;//房间id
		
		public function convertToBytes(bytes:ByteArray, offset:int):int
		{
/*			
			var len:int = 0;
			len += offset;
			bytes.position = offset;
			
			bytes.writeInt(msgSeq);
			len += 4;
			bytes.writeInt(reserve);
			len += 4;

			bytes.writeInt(roomId);
			len += 4;
			return len;
*/			
			//var len:int = 0;
			//len += offset;
			bytes.position = offset;
			
			//bytes.writeInt(msgSeq);
			bytes[offset + 0] = (msgSeq & 0xff);
			bytes[offset + 1] = ((msgSeq >> 8) & 0xff);
			bytes[offset + 2] = ((msgSeq >> 16) & 0xff);
			bytes[offset + 3] = ((msgSeq >> 24) & 0xff);
			//len += 4;
			offset += 4;
			
			//bytes.writeInt(reserve);
			bytes[offset + 0] = (reserve & 0xff);
			bytes[offset + 1] = ((reserve >> 8) & 0xff);
			bytes[offset + 2] = ((reserve >> 16) & 0xff);
			bytes[offset + 3] = ((reserve >> 24) & 0xff);			
			//len += 4;
			offset += 4;

			//bytes.writeInt(roomId);
			bytes[offset + 0] = (roomId & 0xff);
			bytes[offset + 1] = ((roomId >> 8) & 0xff);
			bytes[offset + 2] = ((roomId >> 16) & 0xff);
			bytes[offset + 3] = ((roomId >> 24) & 0xff);		
			//len += 4;	
			offset += 4;
			
			bytes.position = offset;
			bytes.length = offset;			
			return offset;
		}
	}
	
}